package com.sangengblog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sangengblog.domain.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色信息表(Role)表数据库访问层
 *
 * @author makejava
 * @since 2024-04-10 22:04:16
 */
public interface RoleMapper extends BaseMapper<Role> {
    List<String> selectRoleKeyByUserId(Long usrId);

    @Select(value = "select * from sys_role where role_name = #{roleName} and role_key = #{roleKey}")
    Role getRole(Role role);

    @Insert(value = "insert into sys_role_menu values(#{roleId}, #{menuId})")
    void insertRoleMenu(@Param("roleId") Long roleId, @Param("menuId") Long menuId);

    @Delete(value = "delete from sys_role_menu where role_id = #{id}")
    void deleteRoleMenuByRoleId(Long id);
}
